<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>


<body>
  <div id="test"></div>
</body>



<script type="text/javascript" src="../js/react.development.js"></script>
<script type="text/javascript" src="../js/react-dom.development.js"></script>
<script type="text/javascript" src="../js/babel.min.js"></script>
<script type="text/javascript" src="../js/prop-types.js"></script>

<script type="text/babel"> //必须声明 babel
  class Person extends React.Component {
    state = {
      isHot: false
    }
    showInfo = () => {
      const { input1 } = this
      alert(input1.value)
    }
    changeWatter = () => {
      const { isHot } = this.state
      this.setState({
        isHot: !isHot
      })
    }
    saveInput=(c)=>{
      this.input1=c
      console.log(1111, this.input1);
      
    }
    render () {
      const { isHot } = this.state
      return (
        <div>
          <h2>{isHot ? '炎热' : '凉爽'}</h2>
          <br />
          
          {/*    <input type="text" placeholder="请输入内容" ref={c => this.input1 = c} />
          <br />*/}
          <input type="text" placeholder="请输入内容" ref={this.saveInput} />
          <button onClick={this.showInfo}>点击显示输入的数据</button>

          <button onClick={this.changeWatter}>点我切换天气</button>
        </div>
      )
    }
  }
  // ReactDOM.render(<Person name='张三' age='18' sex='男' />, document.getElementById('test'))
  ReactDOM.render(<Person />, document.getElementById('test'))
</script>

</html>